package com.data.ferry.web;

import com.data.ferry.service.WebSocketServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: Administrator
 * @Date: 2019/11/6 00:48
 * @Description:
 */
@RestController
@RequestMapping("/system")
public class WebSoketController {

    /**
     *页面请求
     * @param userId
     * @return
     */
    @GetMapping("/index/{userId}")
    public String socket(@PathVariable String userId){
        return "";
    }

    /**
     * 推送消息接口
     * @param cid
     * @param message
     * @return
     */
    public Map pushToWeb(@PathVariable String cid,String message){
        Map result = new HashMap();
        try {
            WebSocketServer.sendInfo(message,cid);
            result.put("code",200);
            result.put("msg","sucess");
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return result;
    }
}
